package com.hibiscusking.org.service.impl;

import com.hibiscusking.basic.util.PageList;
import com.hibiscusking.org.domain.SystemDictionaryType;
import com.hibiscusking.org.mapper.SystemDictionaryTypeMapper;
import com.hibiscusking.org.query.SystemDictionaryTypeQuery;
import com.hibiscusking.org.service.SystemDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryTypeServiceImpl implements SystemDictionaryTypeService {
    @Autowired
    private SystemDictionaryTypeMapper systemDictionaryTypeMapper;

    @Override
    public List<SystemDictionaryType> findAll() {
        return systemDictionaryTypeMapper.findAll();
    }

    @Override
    public void add(SystemDictionaryType systemDictionaryType) {
        systemDictionaryTypeMapper.add(systemDictionaryType);
    }

    @Override
    public void dele(Long id) {
        systemDictionaryTypeMapper.dele(id);
    }

    @Override
    public void update(SystemDictionaryType systemDictionaryType) {
        systemDictionaryTypeMapper.update(systemDictionaryType);
    }

    @Override
    public PageList<SystemDictionaryType> findQuerySystemDictionaryType(SystemDictionaryTypeQuery query) {
        Integer dictionaryNumber = systemDictionaryTypeMapper.findDictionaryNumber(query);
        if (dictionaryNumber == 0 || dictionaryNumber == null) {
            return new PageList<>();
        }
        List<SystemDictionaryType> querySystemDictionaryType = systemDictionaryTypeMapper.findQuerySystemDictionaryType(query);
        return new PageList<>(dictionaryNumber,querySystemDictionaryType);
    }

    @Override
    public Integer findDictionaryNumber(SystemDictionaryTypeQuery query) {
        return systemDictionaryTypeMapper.findDictionaryNumber(query);
    }
}

